// logs.js
const util = require('../../utils/util.js')
const http = require('../../api/http.js')

Page({
  data: {
    logs: [],
    list: [],
  },
  onLoad() {

    this.setData({
      logs: (wx.getStorageSync('logs') || []).map(log => {
        return {
          date: util.formatTime(new Date(log)),
          timeStamp: log
        }
      })
    })
  },
  onShow() {
    let that = this

    that.setData({
      list: []
    })

    http.top().then(res => {
      if(res.data !== 'login required') {
        that.setData({
          list: res.data
        })
      }
    })
  }
})
